<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
		<title>物料</title>
		<meta http-equiv="expires" content="0">
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<link rel="stylesheet" href="../../../css/reset.css" />
		<link rel="stylesheet" href="../../../css/mui.min.css" />
		<link rel="stylesheet" href="../../../css/iconfont.css" />
		<link rel="stylesheet" href="../../../css/cmms.css" />
		<link rel="stylesheet" href="../../../css/sale/materiel/materiel.css" />
	</head>
	<body>
		<div id="materiel" class="mui-content center panel"  v-cloak>
			<!--搜素-->
			<div class="topSearch">
				<input type="text" v-model="doctorName" :placeholder="icon"  />
				<button class="btn-primary right" @tap="search" v-show="!isBtnShow">搜索</button>
				<span class="right" @tap="apply" v-show="isBtnShow"><i class="iconfont icon-wuliaoguanli"></i>申请</span>
			</div>
			<div class="main">
				<div class="panel" v-for="info in infoList">
					<ul>
						<li>
							<p>
								<span>{{info.partnerHospitalName}}</span>
								<!--<span class="waitCheck">等待 陈文辉 审核</span>-->
								<span class="check">{{info.status+''|formatMateriel}}</span>
							</p>
						</li>
						<li class="itemList">
							<p v-for="item in info.list">{{item.name}} ×{{item.applyNum}} <i class="iconfont icon-shanchu" @tap="cancelOneApply(item.id)"></i></p>
						</li>
						<li>
							<p><span>收件人:{{info.receiverName}}</span><span>{{info.receiverMobile}}</span></p>
							<p>收件地址:{{info.receiveAddress}}</p>
						</li>
						<li>
							<p>
								<span class="time">{{info.applyTime|replaceT}}</span>
								<span class="btn-detail noApply" v-show="info.status<2" @tap="cancelApply(info.id)">取消申请</span>
								<span class="btn-detail" v-show="info.status==1" @tap="editApply(info.id)">修改申请</span>
								<!--<span class="btn-detail" @tap="editApply(info.id)">修改申请</span>-->
								<span class="btn-detail tracking" @tap="logistics(info.expressCompanyCode,info.expressNo)" v-show="info.status>=3">物流跟踪</span>
								<!--<span class="btn-detail tracking" @tap="logistics(info.expressCompanyCode,info.expressNo)">物流跟踪</span>-->
							</p>
						</li>
					</ul>
				</div>
			</div>
		</div>
		<script src="../../../js/mui.min.js"></script>
		<script src="../../../js/vue.js"></script>
		<script src="../../../js/cmms.js?time=3331"></script>
		<script>
			new Vue({
				el:"#materiel",
				data(){
					return{
						doctorName:'',
						isBtnShow:true,
						icon:'请输入客户或医生 \ue604',
						infoList:[]
					}
				},
				watch:{
					doctorName:function(){
						if(this.doctorName!=''){
							this.isBtnShow = false;
						}else{
							this.isBtnShow = true;
							this.search();
						}
					}
				},
				mounted(){
//					var vConsole = new VConsole();
					this.init();
				},
				methods:{
					init(){
						let _this=this;
						AT.muiAjax('/partner-sale/apply/getPartnerConsumableApply','post',{
							 name:_this.doctorName
						},function(realData){
							_this.infoList = realData;
							console.log(realData);
						});
					},
					search(){
						let _this = this;
						AT.muiAjax('/partner-sale/apply/getPartnerConsumableApply','post',{
							 name:_this.doctorName
						},function(realData){
							_this.infoList = realData;
							console.log(realData);
						});
					},
					//申请
					apply(){
						location.href = "materielApply.html?webName=apply";	
					},
					//重新申请
					editApply(id){
						location.href = "materielApply.html?webName=editApply&id="+id;
					},
					//取消申请
					cancelApply(id){
						let _this = this;
						AT.muiAjax('/partner-sale/apply/deleteConsumableApply','post',{
							 id:id
						},function(realData){
							mui.toast("取消成功!");
							const timer = setTimeout(() =>{                    
								location.reload();              
							}, 1000);  
							_this.$once('hook:beforeDestroy', () => {            
							    clearTimeout(timer);                                    
							});
						});
					},
					//删除单条
					cancelOneApply(id){
						let _this = this;
						AT.muiAjax('/partner-sale/apply/deleteConsumableApplyDetail','post',{
							 id:id
						},function(realData){
							mui.toast("删除成功!");
							const timer = setTimeout(() =>{                    
								location.reload();              
							}, 1000);  
							_this.$once('hook:beforeDestroy', () => {            
							    clearTimeout(timer);                                    
							});
						});
					},
					logistics(expressCompanyCode,expressNo){
//						location.href = "https://m.kuaidi100.com/index_all.html?type=shentong&postid=&callbackurl=http:www.baidu.com#result";
						location.href = "https://m.kuaidi100.com/index_all.html?type="+expressCompanyCode+"&postid="+expressNo+"&callbackurl=";
					}
				}	
			})
		</script>
	</body>
</html>

